import EngineContext from "../EngineContext"
import Module from "../module/Module"
import ExtObjData from "./ExtObjData"
import ExtObjViewData from "./ExtObjViewData"

export default class ExtObjViewDataModule extends Module {
  data: ExtObjData
  viewData: ExtObjViewData
  constructor() {
    super(...arguments)
    this.name = "extobj-viewdata"
  }
  async init(e: any, t: EngineContext) {
    this.data = await t.market.waitForData(ExtObjData)
    this.viewData = t.market.tryGetData(ExtObjViewData) || new ExtObjViewData(this.data)
    t.market.register(this, ExtObjViewData, this.viewData)
  }
}
